// -*- coding: utf-8 -*- 
/**
 * Project: Java8InActionT
 * Creator: yanking
 * Create time: 2022-02-22 23:52
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package com.ThreadPool.customThreadPool;

import java.util.List;

public class myWorker extends Thread {
    // 任务队列，队列用于线程的运行
    List<Runnable> taskList;
    // 自定义线程类，用于接收任务类，并且运行
    private String name; // 线程名

    public myWorker(String name, List<Runnable> taskList) {
        this.name = name;
        this.taskList = taskList;
    }

    @Override
    public void run() {
        while (taskList.size() > 0) {
            Runnable r = taskList.remove(0);
            r.run();
        }
    }

    @Override
    public String toString() {
        return "myWorker{" +
                "name='" + name + '\'' +
                '}';
    }
}
